<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row type="flex">
          <a-col>
            <a-button icon="plus" style="margin-right: 20px" type="primary" @click="openAdd()">新增</a-button>
            <a-divider style="margin-right: 20px" type="vertical"/>
          </a-col>
          <a-col :md="4" :sm="6" >
            <a-form-item label="标准编号">
              <j-input v-model="queryParam.code" placeholder="请输入标准名称"></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" style="margin-left: 15px">
            <a-form-item label="标准名称">
              <j-input v-model="queryParam.name" placeholder="请输入标准名称"></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="5" :sm="7" style="margin-left: 15px">
            <a-form-item label="标准类型">
              <a-select v-model="queryParam.type" placeholder="请选择标准类型">
                <a-select-option value="GUO">国标</a-select-option>
                <a-select-option value="HANG">行标</a-select-option>
                <a-select-option value="DI">地标</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col flex="auto">
            <span class="table-page-search-submitButtons" style="float: left; overflow: hidden;margin-right: 20px">
<!--              <a-button icon="search" type="primary" @click="searchQuery">查询</a-button>-->
              <a-popover :overlayStyle="{background: 'white'}" :visible="tooltipShow" placement="topLeft">
                <template slot="content">
                  <a-icon theme="twoTone" two-tone-color="#52c41a" type="exclamation-circle"/><span
                  style="margin-left: 5px">可以点击重置来重新筛选结果</span>
                </template>
                <a-button icon="search" type="primary" @click="searchQuery" style="margin-left: 20px">查询</a-button>
                <a-button
                  icon="reload"
                  style="margin-left: 8px"
                  @click="searchReset"
                >重置</a-button>
              </a-popover>

            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <div>
      <a-table
        ref="table"
        :columns="columns"
        :dataSource="dataSource"
        :loading="loading"
        :pagination="ipagination"
        bordered
        class="Atable"
        rowKey="id"
        size="middle"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a-button style="margin-right: 10px" type="primary" @click="handleEdit(record)">
            编辑
          </a-button>
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a-button>
                删除
              </a-button>
            </a-popconfirm>
        </span>
        <span slot="type" slot-scope="text, record">
          <a-tag v-if="text == 'GUO'" color="red">国标</a-tag>
          <a-tag v-if="text == 'HANG'" color="blue">行标</a-tag>
          <a-tag v-else-if="text == 'DI'" color="green">地标</a-tag>
        </span>
      </a-table>
      <standard-modal ref="modalForm" @ok="modalFormOk"></standard-modal>
    </div>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JInput from '@comp/jeecg/JInput'
import StandardModal from '@views/dataVisualization/components/standardModal'

export default {
  name: 'lowCarbonStandards',
  mixins: [JeecgListMixin],
  components: {
    StandardModal,
    JInput
  },
  data() {
    return {
      tooltipShow: false,
      columns: [
        {
          title: '标准编号',
          dataIndex: 'code',
          align: 'left',
          // scopedSlots: { customRender: 'name' },
          // width:420,
        },
        {
          title: '标准名称',
          dataIndex: 'name',
          align: 'left',
        },
        {
          title: '实施日期',
          dataIndex: 'implementationDate',
          align: 'center',
        },
        {
          title: '发布日期',
          dataIndex: 'releaseDate',
          align: 'center',
        },
        {
          title: '标准类型',
          dataIndex: 'type',
          align: 'center',
          scopedSlots: { customRender: 'type' }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          width: 200,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/carbon/demonstrationPilotCarbonStandard/list',
        delete: '/carbon/demonstrationPilotCarbonStandard/delete'
      }
    }
  },
  methods: {
    openAdd() {
      this.$refs.modalForm.add()
      this.$refs.modalForm.title = '新增'
      this.$refs.modalForm.disableSubmit = false
    },
  },
}
</script>

<style scoped>

</style>